import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    username:sessionStorage.getItem('name'),
    userid:sessionStorage.getItem('id'),
    gouma:'',
    sousuo:'',
    imgBase:'http://localhost:3000'
  },
  getters: {
  },
  mutations: {
    savesousuo(state,payLoad){
      state.sousuo=payLoad
    },
    savegouma(state,payLoad){
      state.gouma=payLoad
    },
    //修改state.username
    saveUsername(state,payLoad){
      state.username=payLoad
      //将用户名存入state
      sessionStorage.setItem('name',payLoad)
    },
    saveUserid(state,payid){
      state.userid=payid
      sessionStorage.setItem('id',payid)
    },
    logout(state){
      state.username=undefined
      sessionStorage.removeItem('name')
    }
  },
  actions: {
  },
  modules: {
  }
})
